package com.example.mykotilin.paging

import android.app.Application
import androidx.lifecycle.ViewModel
import androidx.lifecycle.ViewModelProvider
import java.lang.IllegalArgumentException
import java.security.Provider

class CheeseViewModelFactor(private val app:Application) : ViewModelProvider.Factory {
    override fun <T : ViewModel?> create(modelClass: Class<T>): T {
       if(modelClass.isAssignableFrom(CheeseViewModel::class.java)){
           val cheeseDao = CheeseDb.newInstance(app).cheeseDao()
           @Suppress("UNCHECKED_CAST")
           return CheeseViewModel(cheeseDao) as T;
       }
        throw IllegalArgumentException("Unknown ViewModel class")
    }
}